package com.aode.utils.emoji;

import android.content.Context;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;

import java.util.concurrent.atomic.AtomicInteger;

public final class Utils {
    private static int sKeyboardHeight;
    private Utils(){

    }
    private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);


    public static int generateViewId(){
        for(;;){
            final int result = sNextGeneratedId.get();
            int newValue = result+1;
            if(newValue>0x00FFFFFF)newValue = 1;
            if(sNextGeneratedId.compareAndSet(result,newValue)){
                return result;
            }
        }
    }

    public static int getSoftKeyboardHeight(Context context){
        return 200;
    }

    public static int getScreenHeight(Context context){
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int height = size.y;
        return height;
    }

    public static int getScreenWidth(Context context){
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        return width;
    }
    public static void setKeyboardHeight(int keyboardHeight){
        Utils.sKeyboardHeight = keyboardHeight;
    }

    public static int getsKeyboardHeight(){
        return sKeyboardHeight;
    }

}
